//
//  ViewController.m
//  NSNotificationCenterDemo
//
//  Created by mobao on 16/4/6.
//  Copyright © 2016年 mobao. All rights reserved.
//

#import "ViewController.h"

@interface ViewController (){

}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}


//说明：在本例子中，点击注册通知按钮5秒之后，会发送一个name为“NOTIFICATION_NAME”的通知，在5秒内跳转到第二个页面，5秒时间到，即可接收到通知。
- (IBAction)postNotification:(id)sender {
    
    //延迟3秒
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
        NSDictionary *dic1 = [NSDictionary dictionaryWithObjectsAndKeys:@"这是传递的对象1",@"key", nil];
        
        //注册通知
        [[NSNotificationCenter defaultCenter]postNotificationName:@"NOTIFICATION_NAME1" object:self userInfo:dic1];
        
        //--------------------------------------------------------------
        
        NSDictionary *dic2= [NSDictionary dictionaryWithObjectsAndKeys:@"这是传递的对象2",@"key", nil];
        
        //注册通知
        [[NSNotificationCenter defaultCenter]postNotificationName:@"NOTIFICATION_NAME2" object:self userInfo:dic2];
        
    });
    
    

}

- (IBAction)goSecondView:(id)sender {
    [self performSegueWithIdentifier:@"SEGUE_IDENTIFIER" sender:nil];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
